//
// Created by DELL on 2021/3/8.
//
#include "log.h"
#include "config.h"
#include <iostream>

int main(int argc, char **argv) {
    static sylar::Logger::ptr system_log = SYLAR_LOG_NAME("system");
    SYLAR_LOG_INFO(system_log) << "hello system" << std::endl;
    std::cout << sylar::LoggerMgr::GetInstance()->toYamlString() << std::endl;
    YAML::Node root = YAML::LoadFile("./config/log.yml");
    sylar::Config::LoadFromYaml(root);
    std::cout << "=============" << std::endl;
    std::cout << sylar::LoggerMgr::GetInstance()->toYamlString() << std::endl;
    std::cout << "=============" << std::endl;
    std::cout << root << std::endl;
    SYLAR_LOG_INFO(system_log) << "hello system" << std::endl;
    system_log->setFormatter("%d - %m%n");
    SYLAR_LOG_INFO(system_log) << "hello system" << std::endl;
//   YAML::Node root = YAML::LoadFile("./config/log.yml");
//    sylar::Config::LoadFromYaml(root);
//    SYLAR_LOG_INFO(SYLAR_LOG_NAME("system")) << "hello"<<std::endl;
//    SYLAR_LOG_INFO(SYLAR_LOG_ROOT()) << "hello root";
    sylar::Config::Visit([](sylar::ConfigVarBase::ptr var) {
        SYLAR_LOG_INFO(system_log) << "name=" << var->getName()
                                   << " description=" << var->getDescription()
                                   << " typename=" << var->getTypeName()
                                   << " value=" << var->toString();
    });
}
